package io.renren.modules.pay_account.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.CommonUtils;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.pay_account.dao.V9PayAccountDao;
import io.renren.modules.pay_account.entity.V9PayAccountEntity;
import io.renren.modules.pay_account.service.V9PayAccountService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("v9PayAccountService")
public class V9PayAccountServiceImpl extends ServiceImpl<V9PayAccountDao, V9PayAccountEntity> implements V9PayAccountService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String trade_sn = (String)params.get("trade_sn");
        String username = (String)params.get("username");
        String pay_status = (String)params.get("pay_status");
        String start = (String) params.get("start");
        String end = (String) params.get("end");
        Integer status=null;
        Integer sInteger=0,eInteger=0;
        if (StringUtils.isNotBlank(start)) {
            sInteger= CommonUtils.timeStrToTimeStamp3(start);
            eInteger=CommonUtils.timeStrToTimeStamp3(end);
        }
        IPage<V9PayAccountEntity> page = this.page(
                new Query<V9PayAccountEntity>().getPage(params,"id",false),
                new QueryWrapper<V9PayAccountEntity>()
                        .like(StringUtils.isNotBlank(trade_sn), "trade_sn", "%"+trade_sn+"%")
                        .like(StringUtils.isNotBlank(username), "username", "%"+username+"%")
                        .like(StringUtils.isNotBlank(pay_status), "pay_status", "%"+pay_status+"%")
                        .between(StringUtils.isNotBlank(start), "add_time", sInteger, eInteger));
        return new PageUtils(page);
    }

}
